package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.query.TravelQuery;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;


    /**
     * 查询所有目的地
     */
    @GetMapping("list")
    public Object list(){
        List<Destination> list = destinationService.list();
        return JsonResult.success(list);
    }


    /**
     * 热门区域查询
     */
    @GetMapping("hotRegion")
    public Object getHotRegion(){
        List<Region> regions = regionService.getHotRegion(1);

        return JsonResult.success(regions);
    }

    /**
     * 查询热门区域下的目的地
     */
    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> destinations = destinationService.search(regionId);
        return JsonResult.success(destinations);
    }

    /**
     * 查询吐司导航
     */
    @GetMapping("/toasts")
    public Object toasts(String destId){
        List<Destination> toasts = destinationService.queryToasts(destId);
        return JsonResult.success(toasts);
    }

    /**
     * 目的地下所有攻略分类和详细攻略
     */
    @GetMapping("/catalogs")
    public Object getCatalogs(String destId){
        List<StrategyCatalog> catalogs = strategyCatalogService.queryStrategyCatalogs(destId);
        return JsonResult.success(catalogs);
    }

    /**
     * 查询目的地下点击量前三的攻略
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object getStrategies(String destId){
        List<Strategy> strategies =strategyService.queryStrategies(destId);
        return JsonResult.success(strategies);
    }
    /**
     * 查询目的地下点击量前三的游记
     */
    @GetMapping("/travels/viewnumTop3")
    public Object getTravels(String destId){
        List<Travel> travels= travelService.queryTravels(destId);
        return JsonResult.success(travels);
    }
}
